package structure.composite;

import java.util.Collections;
import java.util.List;

/**
 * @author lzp
 * @Date:2023/2/24
 * @description: 文本内容，没有子节点
 */
public class TextNode implements Node {
	private String text;

	public TextNode(String text) {
		this.text = text;
	}

	@Override
	public Node add(Node node) {
		throw new UnsupportedOperationException();
	}

	@Override
	public List<Node> children() {
		return Collections.EMPTY_LIST;
	}

	@Override
	public String toXML() {
		return text+"\n";
	}
}
